'use client'

import React, { ReactNode } from 'react'
import { 
  Dialog, 
  DialogContent, 
  DialogHeader, 
  DialogTitle,
  DialogFooter,
} from './dialog'

interface DialogWrapperProps {
  isOpen: boolean
  onClose: () => void
  title?: string
  size?: 'sm' | 'md' | 'lg' | 'xl' | 'full'
  children: ReactNode
}

const getSizeClass = (size?: string) => {
  switch(size) {
    case 'sm': return 'max-w-sm'
    case 'md': return 'max-w-md'
    case 'lg': return 'max-w-lg'
    case 'xl': return 'max-w-xl'
    case 'full': return 'max-w-[90vw]'
    default: return 'max-w-md'
  }
}

export default function DialogWrapper({ 
  isOpen, 
  onClose, 
  title, 
  size = 'md',
  children 
}: DialogWrapperProps) {
  const sizeClass = getSizeClass(size)

  return (
    <Dialog open={isOpen} onOpenChange={(open) => {
      if (!open) onClose()
    }}>
      <DialogContent className={sizeClass}>
        {title && (
          <DialogHeader>
            <DialogTitle>{title}</DialogTitle>
          </DialogHeader>
        )}
        {children}
      </DialogContent>
    </Dialog>
  )
} 